package com.yanqu.road.server.cmd.activity.metaspace;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.pb.activity.MetaSpaceProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.metaspace.MetaspaceModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.List;

@Cmd(code = GameProtocol.S_META_SPACE_FILL_DATA, desc = "")
public class FillMetaSpaceRewardDataCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        MetaSpaceProto.FillMetaSpaceReqMsg req = MetaSpaceProto.FillMetaSpaceReqMsg.parseFrom(packet.getBytes());
        List<ActivityInfo> openActivityInfoList = NormalActivityMgr.getOpenActivityInfoList(eActivityType.MetaSpace.getValue());
        int activityId = 1;
        if (openActivityInfoList.size() > 0) {
            ActivityInfo activityInfo = openActivityInfoList.get(0);
            activityId = activityInfo.getActivityId();
        }
        int id = req.getId();
        String address = req.getAddress();
        long phoneNum = req.getPhoneNum();
        ret = player.getModule(MetaspaceModule.class).fillContactInfo(activityId, id, phoneNum, address);
        MetaSpaceProto.FillMetaSpaceRespMsg.Builder resp = MetaSpaceProto.FillMetaSpaceRespMsg.newBuilder();
        resp.setRet(ret);
        player.sendPacket(ClientProtocol.U_META_SPACE_FILL_DATA, resp);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
